home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-08-12 | 705 b | 34 lines | [TEXT/KEEN] |
- #$EnteringFunction: ad debugging to a hAWK program with functions,
- # inserting print statements at beginning of each function.
- # Pass it your problem program as the single input file:
- # overwrites the file.
- FNR == 1 {outfile = FILENAME}
-
- {
- if (match($0, /^[ \t]*func/)) #start of function definition
- {
- name = $2
- len = index(name, "(")
- if (len+0 > 1)
- name = substr(name,1,len-1)
- out[++i] = $0
- # Skip over opening left curly of function
- if ($0 !~ /{/)
- {
- do
- {
- getline
- out[++i] = $0
- } while ($0 !~ /{/);
- }
- out[++i] = "print \"Entering: \"\"" name "\" ###"
- }
- else
- out[++i] = $0
- }
-
- END { close(outfile)
- for (j = 1; j <= i; ++j)
- print out[j] > outfile
- }
-